package com.hbnu.serializable;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * @author kittychen
 * @since 2025-10-17 17:43
 */
public class SerializableTest2 {

    public static void main(String[] args) {
        String path = "C:" + File.separator + "Users" + File.separator + "Administrator"
                + File.separator + "Desktop" + File.separator + "kittychen"
                + File.separator + "class2311" + File.separator + "object.txt";
        File file = new File(path);

        ObjectInputStream objectInputStream = null;

        try {
            objectInputStream = new ObjectInputStream(new FileInputStream(file));

            Person person = (Person) objectInputStream.readObject();

            System.out.println(person);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (objectInputStream != null) {
                    objectInputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
